import json
import os

from yaml import load, loader

from src.config.schemas import Configs


def load_configs() -> Configs:
    env = os.environ.get("ENV") if os.environ.get("ENV") is not None else "dev"
    curpath = os.path.dirname(os.path.realpath(__file__))
    yamlpath = os.path.join(curpath, f"bootstrap-{env}.yaml")
    f = open(yamlpath, "r", encoding="utf-8")
    root_dict = load(f.read(), loader.FullLoader)
    return Configs.from_json(json.dumps(root_dict, ensure_ascii=False))


cfg: Configs = load_configs()
